<%@page import="com.mconnect.msurvey.model.Report"%>
<%@page import="com.mconnect.msurvey.controller.PlanManager"%>
<%@page import="com.mconnect.msurvey.controller.UserManager"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.mconnect.msurvey.model.User"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

 <link rel="stylesheet" href="resources/css/ap.css">
  <link rel="stylesheet" href="js/jQuery/themes/base/jquery.ui.all.css">
  <link rel="stylesheet" href="js/jQuery/demos.css">
  <link rel="stylesheet" href="resources/css/detail_style.css">
  
	 <style>
		body { font-size: 62.5%; }
		label, input { display:block; }
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
	</style>

</head>
<body>
	<% 	List<User> userList = new ArrayList<User>();
		UserManager uM = new UserManager();
		int id_plan =0;
		userList = uM.getAllUsersFromDB();
		PlanManager pM = new PlanManager();
		String dateFrom = request.getParameter("dateFrom");
		String dateTo = request.getParameter("dateTo");
		
	%>

	<center>
	
	<div id="users-contain" class="ui-widget" style="width: 915px; ">
		<table id="users" class="ui-widget ui-widget-content" >
			<thead>
				<tr class="ui-widget-header ">
					<th style="width: 150px;"></th>
					<th style="width: 85px;">Ankiet</th>
					<th style="width: 85px;">Ankiet HR</th>
					<th style="width: 85px;">Wszystkich ankiet</th>
					<th style="width: 85px;">Poleceń</th>
					<th style="width: 85px;">Poleceń HR</th>
					<th style="width: 85px;">Wszystkich poleceń</th>
					<th style="width: 85px;">Realizacja planu</th>
					<th style="width: 85px;">Potwierdziło przybycie</th>
					<th style="width: 85px;">Pozyskanych peseli</th>
				</tr>
			<tbody>
				<% for(User user: userList){ 
					Report report = pM.getReportByIdUser(user.getId_user(), dateFrom, dateTo);
					int numberOfSurveys = report.getNumberOfSurveys();
					int numberOfSurveysHR = report.getNumberOfSurveysHR();
					int totalSurveys = report.getTotalSurveys();
					int numberOfConfirms = report.getNumberOfConfirms();
		    		double realizationPlan = pM.getRealizationOfPlan(numberOfConfirms, numberOfSurveys);
		    		int numberOfRecommend = report.getNumberOfRecommend();
		    		int numberOfRecommendHR = report.getNumberOfRecommendHr();
		    		int totalRecommend = report.getTotalRecommend();
		    		int numberOfPesels = report.getNumberOfPesels();
				%>
					<tr>
						<td><%= user.getFirstname() + " " + user.getLastname() %></td>
						<td><%= numberOfSurveys %></td>
						<td><%= numberOfSurveysHR %></td>
						<td><%= totalSurveys %></td>
						<td><%= numberOfRecommend %></td>
						<td><%= numberOfRecommendHR %></td>
						<td><%= totalRecommend %></td>
						<td><%= realizationPlan %>%</td>
						<td><%= numberOfConfirms %></td>
						<td><%= numberOfPesels %></td>
					</tr>
				<%} %>
			</tbody>	
		</table>
		</div>
	</center>
	
</body>
</html>